-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local filenames with colon should be parsed correctly #35123
Conversation
Summary: **Context** On RN Desktop, images can be copy/pasted into text inputs. When copy/pasting local files w/ semi-colons in the filename (`/downloads/devices:pre-call-IMG_346C38284B2B-1.jpeg`), RN would throw this error. {F785684529} The error was due to no having the correct asset loader due to the local file path being parsed incorrectly. To parse the url, we convert the string URI to a `NSURL` using a custom convertor fn. The conversion was matching any `:` and assuming it was a network url scheme: https://www.internalfb.com/code/archon_react_native_macos/[fde4113acd89fb13ee11636c48b59eac49c21bae]/React/Base/RCTConvert.m?lines=97-111 When an image path with `:` in the name was passed to this, it was assuming it was a valid network url and not file path. Because this is a local filepath, the image path needs to be a filesystem url. Since this was parsed as network url, it did not have the `file://` prefix and would not pass this check, causing the loader to throw.l https://www.internalfb.com/code/fbsource/%5B60d9d5e67383%5D/xplat/js/react-native-github/Libraries/Image/RCTImageLoader.mm?lines=220-230 ## Changelog [iOS] [Added] - Add support for parsing files w/ `:` in filename Reviewed By: christophpurrer Differential Revision: D40729963 fbshipit-source-id: 84cdca979d331f8704aa5f67de6f11e571abd474
This pull request was exported from Phabricator. Differential Revision: D40729963 |
This pull request was successfully merged by @shwanton in 714b22b. When will my fix make it into a release? | Upcoming Releases |
@shwanton I believe this change has broken "mailto:test@example.com" links on iOS. For example doing Linking.openURL("mailto:test@example.com") is no longer working on iOS devices. |
Thanks for catching this, I don't think we had a test for this case so I'll add one & fix the |
@jamesthomp I just confirmed w/ RNTester that react-native/React/Base/RCTConvert.m Lines 88 to 91 in 9ee0e1c
If you are seeing "unresolved promises" when Linking a |
Summary: Pull Request resolved: facebook#35123 **Context** On RN Desktop, images can be copy/pasted into text inputs. When copy/pasting local files w/ semi-colons in the filename (`/downloads/devices:pre-call-IMG_346C38284B2B-1.jpeg`), RN would throw this error. {F785684529} The error was due to no having the correct asset loader due to the local file path being parsed incorrectly. To parse the url, we convert the string URI to a `NSURL` using a custom convertor fn. The conversion was matching any `:` and assuming it was a network url scheme: https://www.internalfb.com/code/archon_react_native_macos/[fde4113acd89fb13ee11636c48b59eac49c21bae]/React/Base/RCTConvert.m?lines=97-111 When an image path with `:` in the name was passed to this, it was assuming it was a valid network url and not file path. Because this is a local filepath, the image path needs to be a filesystem url. Since this was parsed as network url, it did not have the `file://` prefix and would not pass this check, causing the loader to throw.l https://www.internalfb.com/code/fbsource/%5B60d9d5e67383%5D/xplat/js/react-native-github/Libraries/Image/RCTImageLoader.mm?lines=220-230 ## Changelog [iOS] [Added] - Add support for parsing files w/ `:` in filename Reviewed By: christophpurrer, philIip Differential Revision: D40729963 fbshipit-source-id: 2f3adcabc8f0f1f22cbfca69c3484e72b1d93d25
Summary:
On RN Desktop, images can be copy/pasted into text inputs.
When copy/pasting local files w/ semi-colons in the filename (
/downloads/devices:pre-call-IMG_346C38284B2B-1.jpeg
), RN would throw this error.This was due to not having the correct asset loader because the local file path being parsed incorrectly.
To parse the url, we convert the string URI to a
NSURL
using a custom convertor fn.The conversion was matching any
:
and assuming it was a network url scheme:https://github.com/facebook/react-native/blob/main/React/Base/RCTConvert.m#L93-L107
When an image path with
:
in the name was passed to this, it was assuming it was a valid network url and not file path.Because this is a local filepath, the image path needs to be a filesystem url. Since this was parsed as network url, it did not have the
file://
prefix and would not pass this check, causing the loader to throw.https://github.com/facebook/react-native/blob/main/Libraries/Image/RCTImageLoader.mm#L220-L231
Changelog
[iOS] [Added] - Add support for parsing local files w/
:
in filenameReviewed By: christophpurrer
Differential Revision: D40729963